shift-or algorithm